package com.qing.springbootdispatcherservice.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class DispatchService {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	//处理运单
	public void dispatch(String  orderId) throws Exception {
		String sqlString="INSERT INTO `dispatcher_order`.`dispatcher_order` (`order_id`, `status`, `order_content`, `unique_id`) VALUES (?, ?, ?, ?)";
		int count=jdbcTemplate.update(sqlString,orderId,0,"骑手已经接单", UUID.randomUUID().toString());
		if(count!=1){
			throw new Exception("运单创建失败，原因【数据库操作失败哦】");
		}
	}
}
